<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>首页</title>
    <style>
        body{
            margin: 0 auto;
            text-align: center;
            background-image: url("img/img.png");
            background-size: cover;
        }
    </style>
</head>
<body>
<h1 style="color: white">启明星的指引</h1>
<h3 style="color: white">The guide of the daystar</h3>
<div style="width: 400px;height: 100px;background-color: rgba(255,255,255,0.35);margin: 0 auto;padding: 100px">
    用户名:<input type="text" v-model="user.username" placeholder="请输入用户名" style="margin-left: 5px;width: 300px"><br>
    密 码:<input type="password" v-model="user.password" placeholder="请输入密码" style="margin: 10px 0 20px 16px;width: 300px"><br>
    <a href="/reg.html"><input type="button" value="注册"></a>
    <input type="button" value="登录" @click="login()">
</div>
<script src="js/vue.js"></script>
<script src="js/axios.min.js"></script>

<script>
    let v = new Vue({
        el:"div",
        data:{
            user:{username:"",password:""}
        },
        methods:{
            login(){
                axios.post("/login",v.user).then(function (response){
                    if(response.data==1){
                        location.href="/list.html";
                    }else if(response.data==2) {
                        alert("用户不存在!")
                        location.reload();
                    }else{
                        alert("密码错误!");
                        location.reload();
                    }
                })
            }
        }
    })
</script>
</body>
</html>